package CrowdCounting.RunnableTask.CrowdCountingTask.CCShowLabelTaskImp;

import CrowdCounting.Model.CrowdCounting.CrowdCountingDisplayFrame;
import CrowdCounting.Model.Util;
import CrowdCounting.RunnableTask.CrowdCountingTask.CCShowLabelTask;

import javax.swing.*;
import java.awt.*;
import java.io.File;

public class CCShowImageLabelTaskProxy extends CCShowLabelTask {
    File imageFile;
    private String imagePathRoot;
    private int imageLength;
    private CCShowImageLabelTask ccShowImageLabelTask;
    private boolean isFirst = true;

    public CCShowImageLabelTaskProxy(CrowdCountingDisplayFrame crowdCountingDisplayFrame, JLabel imageLabel, String imagePathRoot) {
        this.crowdCountingDisplayFrame = crowdCountingDisplayFrame;
        this.label = imageLabel;
        this.imagePathRoot = imagePathRoot;
        imageLength = Integer.valueOf(Util.loadProperties("config.properties").getProperty("imageMaxNum"));
        ccShowImageLabelTask = new CCShowImageLabelTask(crowdCountingDisplayFrame, imageLabel, imagePathRoot);
        imageFile = new File(imagePathRoot + "\\image1.png");
    }

    @Override
    public void showLabel() {
        if (isFirst && !imageFile.exists()) {
            isFirst = false;
            label.setText("数据加载中请稍后......");
            label.setFont(new Font(null, Font.BOLD, 30));
            label.repaint();
        }
        ccShowImageLabelTask.showLabel();
    }
}
